#include <cstdint>
#include <iostream>
#include <istream>

using ll = int64_t;
using std::cin, std::cout;

const ll maxn = 500000 + 5;
ll n, m, bit[maxn];

ll lb(const ll &n){
    return n&(-n);
}

void rgadd(ll l, ll r, const ll &k){
    ++r;
    while(l<=n){
        bit[l]+=k;
        l+=lb(l);
    }
    while(r<=n){
        bit[r]-=k;
        r+=lb(r);
    }
}

int main(){
    std::iostream::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

    cin>>n>>m;
    for(ll i{1};i<=n;i++){
        ll a;
        cin>>a;
        rgadd(i, i, a);
    }
    for(ll i{1};i<=m;i++){
        ll t;
        cin>>t;
        if(t==1){
            ll x, y, k;
            cin>>x>>y>>k;
            rgadd(x, y, k);
        }else{
            ll x;
            cin>>x;
            ll res{};
            while(x!=0){
                res+=bit[x];
                x-=lb(x);
            }
            cout<<res<<'\n';
        }
    }
}